define(['jquery','api','Vue','text!pages/index/subscribe.html','util'],function($,api,Vue,tpl,util){
	var vm;
	return {
		init:function(){
			api.setTitle(L('html_title_index_subscribe'));
		   	api.footerShow(1);//底部导航隐藏
		   	
			if(vm){
		   	   vm.show = true;
		   }else{
		   	var qrcode='';
		   		$.ajax({
	    			url:util.url('qrcode'),
	    		    data:{wxdomain:location.host},
	    		    async:false,
	    		    dataType:'json',
	    		    success:function(rs){
	    		    	if(rs.retcode==='0'){
	    		    	    if(rs.qrcode&&rs.qrcode.qrcode!=''){
	    		    	    	qrcode=rs.qrcode.qrcode;
	    		    	    	location.hash='#/index/subscribe';
	    		    	    }
	    		    	}
	    		    }
	    	   });
		   	
		   	
//				var code=api.getQrcode();
				$('#pages').append('<div id="producttrader"></div>');
			    vm = new Vue({
	            	el: '#producttrader',
	              	data: {
	              		show:true,
	              		qrcode:'data:image/png;base64,'+qrcode
	              	},
	              	template:tpl
	            });
		   } 
			  
		},
		onRouteChange:function(){
			if(vm){
	    		vm.show=false;
	    	}
		    $('#page').html('');
		}
   
	}
});